package com.sqlcheck.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import lombok.Data;

import java.time.Duration;
import java.util.List;

@Configuration
@ConfigurationProperties(prefix = "app")
@Data
public class AppProperties {
    
    private GitLab gitlab = new GitLab();
    private Security security = new Security();
    private File file = new File();
    private Analysis analysis = new Analysis();
    
    @Data
    public static class GitLab {
        private String baseUrl;
        private String clientId;
        private String clientSecret;
        private String redirectUri;
        private Duration timeout = Duration.ofSeconds(30);
    }
    
    @Data
    public static class Security {
        private String encryptionKey;
        private Duration sessionTtl = Duration.ofMinutes(30);
        private Cors cors = new Cors();
        
        @Data
        public static class Cors {
            private List<String> allowedOrigins = List.of("http://localhost:3000");
            private List<String> allowedMethods = List.of("GET", "POST", "PUT", "DELETE", "OPTIONS");
            private List<String> allowedHeaders = List.of("*");
            private boolean allowCredentials = true;
            private long maxAge = 3600;
        }
    }
    
    @Data
    public static class File {
        private String tempDir = "/tmp/sqlcheck";
        private String reportDir = "./reports";
        private String maxFileSize = "100MB";
        private Duration cleanupInterval = Duration.ofHours(1);
        private int retentionDays = 7;
    }
    
    @Data
    public static class Analysis {
        private int maxConcurrentTasks = 5;
        private Duration taskTimeout = Duration.ofMinutes(30);
        private int threadPoolSize = 10;
        private int queueCapacity = 100;
    }
}